package com.xxx.optional;

import java.util.Optional;

public class Optionsl {
    public static void main(String[] args) {
        Student student = new Student("张山", 22, "男", 92);
        //of()对像不能为空
//        Optional<Student> student1 = Optional.of(student);
//ofNullable
        Optional<Student> optional = Optional.ofNullable(student);
        System.out.println("student = " + student.getName());
        if (student != null) {

        } else {

        }
        System.out.println();

        Student student1 = optional.orElse(new Student("张山", 22, "男", 66));
        System.out.println("student1 = " + student1);
    }
}
